{"ast":null,"code":"import { supportBigInt } from \"./supportUtil\";\n/**\n * Format string number to readable number\n */\n\nexport function trimNumber(numStr) {\n  var str = numStr.trim();\n  var negative = str.startsWith('-');\n  if (negative) {\n    str = str.slice(1);\n  }\n  str = str // Remove decimal 0. `1.000` => `1.`, `1.100` => `1.1`\n  .replace(/(\\.\\d*[^0])0*$/, '$1') // Remove useless decimal. `1.` => `1`\n  .replace(/\\.0*$/, '') // Remove integer 0. `0001` => `1`, 000.1' => `.1`\n  .replace(/^0+/, '');\n  if (str.startsWith('.')) {\n    str = \"0\".concat(str);\n  }\n  var trimStr = str || '0';\n  var splitNumber = trimStr.split('.');\n  var integerStr = splitNumber[0] || '0';\n  var decimalStr = splitNumber[1] || '0';\n  if (integerStr === '0' && decimalStr === '0') {\n    negative = false;\n  }\n  var negativeStr = negative ? '-' : '';\n  return {\n    negative: negative,\n    negativeStr: negativeStr,\n    trimStr: trimStr,\n    integerStr: integerStr,\n    decimalStr: decimalStr,\n    fullStr: \"\".concat(negativeStr).concat(trimStr)\n  };\n}\nexport function isE(number) {\n  var str = String(number);\n  return !Number.isNaN(Number(str)) && str.includes('e');\n}\n/**\n * [Legacy] Convert 1e-9 to 0.000000001.\n * This may lose some precision if user really want 1e-9.\n */\n\nexport function getNumberPrecision(number) {\n  var numStr = String(number);\n  if (isE(number)) {\n    var precision = Number(numStr.slice(numStr.indexOf('e-') + 2));\n    var decimalMatch = numStr.match(/\\.(\\d+)/);\n    if (decimalMatch !== null && decimalMatch !== void 0 && decimalMatch[1]) {\n      precision += decimalMatch[1].length;\n    }\n    return precision;\n  }\n  return numStr.includes('.') && validateNumber(numStr) ? numStr.length - numStr.indexOf('.') - 1 : 0;\n}\n/**\n * Convert number (includes scientific notation) to -xxx.yyy format\n */\n\nexport function num2str(number) {\n  var numStr = String(number);\n  if (isE(number)) {\n    if (number > Number.MAX_SAFE_INTEGER) {\n      return String(supportBigInt() ? BigInt(number).toString() : Number.MAX_SAFE_INTEGER);\n    }\n    if (number < Number.MIN_SAFE_INTEGER) {\n      return String(supportBigInt() ? BigInt(number).toString() : Number.MIN_SAFE_INTEGER);\n    }\n    numStr = number.toFixed(getNumberPrecision(numStr));\n  }\n  return trimNumber(numStr).fullStr;\n}\nexport function validateNumber(num) {\n  if (typeof num === 'number') {\n    return !Number.isNaN(num);\n  } // Empty\n\n  if (!num) {\n    return false;\n  }\n  return (\n    // Normal type: 11.28\n    /^\\s*-?\\d+(\\.\\d+)?\\s*$/.test(num) ||\n    // Pre-number: 1.\n    /^\\s*-?\\d+\\.\\s*$/.test(num) ||\n    // Post-number: .1\n    /^\\s*-?\\.\\d+\\s*$/.test(num)\n  );\n}","map":{"version":3,"names":["supportBigInt","trimNumber","numStr","str","trim","negative","startsWith","slice","replace","concat","trimStr","splitNumber","split","integerStr","decimalStr","negativeStr","fullStr","isE","number","String","Number","isNaN","includes","getNumberPrecision","precision","indexOf","decimalMatch","match","length","validateNumber","num2str","MAX_SAFE_INTEGER","BigInt","toString","MIN_SAFE_INTEGER","toFixed","num","test"],"sources":["/data/messenger.client/node_modules/@rc-component/mini-decimal/es/numberUtil.js"],"sourcesContent":["import { supportBigInt } from \"./supportUtil\";\n/**\n * Format string number to readable number\n */\n\nexport function trimNumber(numStr) {\n  var str = numStr.trim();\n  var negative = str.startsWith('-');\n\n  if (negative) {\n    str = str.slice(1);\n  }\n\n  str = str // Remove decimal 0. `1.000` => `1.`, `1.100` => `1.1`\n  .replace(/(\\.\\d*[^0])0*$/, '$1') // Remove useless decimal. `1.` => `1`\n  .replace(/\\.0*$/, '') // Remove integer 0. `0001` => `1`, 000.1' => `.1`\n  .replace(/^0+/, '');\n\n  if (str.startsWith('.')) {\n    str = \"0\".concat(str);\n  }\n\n  var trimStr = str || '0';\n  var splitNumber = trimStr.split('.');\n  var integerStr = splitNumber[0] || '0';\n  var decimalStr = splitNumber[1] || '0';\n\n  if (integerStr === '0' && decimalStr === '0') {\n    negative = false;\n  }\n\n  var negativeStr = negative ? '-' : '';\n  return {\n    negative: negative,\n    negativeStr: negativeStr,\n    trimStr: trimStr,\n    integerStr: integerStr,\n    decimalStr: decimalStr,\n    fullStr: \"\".concat(negativeStr).concat(trimStr)\n  };\n}\nexport function isE(number) {\n  var str = String(number);\n  return !Number.isNaN(Number(str)) && str.includes('e');\n}\n/**\n * [Legacy] Convert 1e-9 to 0.000000001.\n * This may lose some precision if user really want 1e-9.\n */\n\nexport function getNumberPrecision(number) {\n  var numStr = String(number);\n\n  if (isE(number)) {\n    var precision = Number(numStr.slice(numStr.indexOf('e-') + 2));\n    var decimalMatch = numStr.match(/\\.(\\d+)/);\n\n    if (decimalMatch !== null && decimalMatch !== void 0 && decimalMatch[1]) {\n      precision += decimalMatch[1].length;\n    }\n\n    return precision;\n  }\n\n  return numStr.includes('.') && validateNumber(numStr) ? numStr.length - numStr.indexOf('.') - 1 : 0;\n}\n/**\n * Convert number (includes scientific notation) to -xxx.yyy format\n */\n\nexport function num2str(number) {\n  var numStr = String(number);\n\n  if (isE(number)) {\n    if (number > Number.MAX_SAFE_INTEGER) {\n      return String(supportBigInt() ? BigInt(number).toString() : Number.MAX_SAFE_INTEGER);\n    }\n\n    if (number < Number.MIN_SAFE_INTEGER) {\n      return String(supportBigInt() ? BigInt(number).toString() : Number.MIN_SAFE_INTEGER);\n    }\n\n    numStr = number.toFixed(getNumberPrecision(numStr));\n  }\n\n  return trimNumber(numStr).fullStr;\n}\nexport function validateNumber(num) {\n  if (typeof num === 'number') {\n    return !Number.isNaN(num);\n  } // Empty\n\n\n  if (!num) {\n    return false;\n  }\n\n  return (// Normal type: 11.28\n    /^\\s*-?\\d+(\\.\\d+)?\\s*$/.test(num) || // Pre-number: 1.\n    /^\\s*-?\\d+\\.\\s*$/.test(num) || // Post-number: .1\n    /^\\s*-?\\.\\d+\\s*$/.test(num)\n  );\n}"],"mappings":"AAAA,SAASA,aAAa,QAAQ,eAAe;AAC7C;AACA;AACA;;AAEA,OAAO,SAASC,UAAU,CAACC,MAAM,EAAE;EACj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